package com.tarena.lbs.basic.web.repository.impl;

import com.tarena.lbs.basic.web.mapper.BusinessMapper;
import com.tarena.lbs.basic.web.mapper.StoreMapper;
import com.tarena.lbs.basic.web.repository.BusinessRepository;
import com.tarena.lbs.common.basic.converter.BusinessConverter;
import com.tarena.lbs.common.basic.converter.StoreConverter;
import com.tarena.lbs.pojo.basic.bo.BusinessBO;
import com.tarena.lbs.pojo.basic.bo.StoreBO;
import com.tarena.lbs.pojo.basic.dos.BusinessDO;
import com.tarena.lbs.pojo.basic.dos.StoreDO;
import com.tarena.lbs.pojo.basic.query.BusinessQuery;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;


@Service
public class BusinessRepositoryImpl implements BusinessRepository {

    @Autowired
    private BusinessMapper businessMapper;

    @Autowired
    private StoreMapper storeMapper;

    @Autowired
    private BusinessConverter businessConverter;
    @Autowired
    private StoreConverter storeConverter;

    @Override
    public void insert(BusinessDO businessDO) {
        businessMapper.insert(businessDO);
    }

    @Override
    public BusinessBO detail(Integer id) {

        BusinessDO businessDO = businessMapper.selectByPrimaryKey(id);
        return businessConverter.do2bo(businessDO);
    }

    @Override
    public void update(BusinessDO record) {
        businessMapper.updateByPrimaryKeySelective(record);
    }

    @Override
    public List<BusinessDO> selectList(BusinessQuery businessQuery) {
        List<BusinessDO> businessDOS = businessMapper.selectList(businessQuery);
        return businessDOS;
    }

    @Override
    public List<BusinessBO> selectAll(Integer businessStatus) {
        List<BusinessDO> businessDOS = businessMapper.selectAll(businessStatus);
        List<BusinessBO> boList = businessConverter.doList2boList(businessDOS);
        return boList;
    }

    @Override
    public List<StoreBO> selectByBuIdcon(Integer id) {
        List<StoreDO> list =storeMapper.selectByBuIdcon(id);
        List<StoreBO> storeBOS = storeConverter.doList2boList(list);
        return storeBOS;
    }
}
